package net.ojbk.study.twobox.beans.form.post;

import net.ojbk.study.twobox.beans.form.InputItem;
import net.ojbk.study.twobox.beans.po.Class;
import net.ojbk.study.twobox.beans.vo.SelectOption;
import net.ojbk.study.twobox.dao.ClassMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: twobox
 * Date: 2019/4/18
 * Time: 10:40
 * Description: No Description
 */
@Component
public class ClassPostForm extends SupperPostForm<Class> {

    private InputItem inputItemLesson = new InputItem("所属课程",
            "lessontypeid",
            "", "select");
    private InputItem inputItemStaff = new InputItem("教师", "teacherid", "", "select", null);
    private InputItem inputItemUser = new InputItem("班主任", "userid", "", "select", null);

    public ClassPostForm() throws Exception {

        this.inputItems.add(new InputItem("班级名称",
                "classname",
                "",
                "text"));
        this.inputItems.add(new InputItem("开班时间",
                "begintime",
                "",
                "date"));

        this.inputItems.add(new InputItem("毕业时间",
                "endtime",
                "",
                "date"));

        //未开课、已开课、已结束
        List<SelectOption> selectOptions = new ArrayList<>();
        selectOptions.add(new SelectOption("未开课", "未开课"));
        selectOptions.add(new SelectOption("已开课", "已开课"));
        selectOptions.add(new SelectOption("已结束", "已结束"));
        this.inputItems.add(new InputItem("状态",
                "cstate",
                "未开课",
                "select", selectOptions));

        this.inputItems.add(inputItemStaff);
        this.inputItems.add(inputItemUser);


        this.inputItems.add(new InputItem("学生总数",
                "totalcount",
                "",
                "text"));

        this.inputItems.add(new InputItem("升学数",
                "gocount",
                "",
                "text"));

        this.inputItems.add(new InputItem("留班数",
                "leavecount",
                "",
                "text"));

        this.inputItems.add(inputItemLesson);

        this.inputItems.add(new InputItem("备注",
                "remark",
                "",
                "text"));


    }

    @Override
    public List<InputItem> getInputItems() throws Exception {
        this.inputItemLesson.setOther(this.selectOptionUtil.getSelectOptionListByName("lesson"));
        inputItemStaff.setOther(this.selectOptionUtil.getSelectOptionListByName("staff"));
        inputItemUser.setOther(this.selectOptionUtil.getSelectOptionListByName("staff"));
        return super.getInputItems();
    }
}
